package com.winhxd.b2c.common.feign.order;

import com.winhxd.b2c.common.constant.BusinessCode;
import com.winhxd.b2c.common.constant.ServiceName;
import com.winhxd.b2c.common.domain.PagedList;
import com.winhxd.b2c.common.domain.ResponseResult;
import com.winhxd.b2c.common.domain.order.condition.*;
import com.winhxd.b2c.common.domain.order.vo.*;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;

/**
 * @description: 后台管理-订单模块
 * @author: shijinxing
 * @create: 2019-01-08 15:59
 **/
@FeignClient(value = ServiceName.ORDER_SERVICE, fallbackFactory = OrderManagementServicerClientFallback.class)
public interface OrderManagementServiceClient {
    /**
     * @description: 根据订单状态查询审核信息
     * @author: shijinxing
     * @create: 2019-01-07 15:59
     **/
    @RequestMapping(value = "/orderManagement/4050/v1/findOrderManagementList", method = RequestMethod.POST)
    ResponseResult<PagedList<OrderManagementListVO>> findOrderManagementList(@RequestBody OrderManagementListCondition condition);
    /**
    * @Description:查询待发货详情
    * @Author: liuhanning
    * @Date:  2019-01-09 16:13
    */
    @RequestMapping(value = "/orderManagement/4061/v1/getDeliverGoods", method = RequestMethod.POST)
     ResponseResult<OrderDeliverGoodsInfoVO> getDeliverGoodsInfo(@RequestBody OrderDeliverGoodsInfoCondition condition) ;
    /**
     * @Description:发货
     * @Author: liuhanning
     * @Date:  2019-01-09 16:13
     */
    @RequestMapping(value = "/orderManagement/4062/v1/saveDeliverGoods", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ResponseResult<Integer> saveDeliverGoods(@RequestBody OrderDeliverGoodsInfoCondition condition);

    /**
     * @description: 购物清单
     * @author: shijinxing
     * @create: 2019-01-07 15:59
     **/
    @RequestMapping(value = "/orderManagement/4051/v1/findShoppingList", method = RequestMethod.POST)
    ResponseResult<OrderShoppingListVO> findShoppingList(@RequestBody OrderShoppingListCondition condition);
    /**
     * @description: 配货清单
     * @author: shijinxing
     * @create: 2019-01-07 15:59
     **/
    @RequestMapping(value = "/orderManagement/4052/v1/findDistributionList", method = RequestMethod.POST)
    ResponseResult<OrderDistributionListVO> findDistributionList(@RequestBody OrderDistributionListCondition condition);
    /**
     * @description: 订单详情
     * @author: shijinxing
     * @create: 2019-01-07 15:59
     **/
    @RequestMapping(value = "/orderManagement/4053/v1/findOrderDetails", method = RequestMethod.POST)
    ResponseResult<OrderManagementDetailsVO> findOrderDetails(@RequestBody OrderDetailsCondition condition);
    /**
     * @description: 关闭订单
     * @author: shijinxing
     * @create: 2019-01-09 15:59
     **/
    @RequestMapping(value = "/orderManagement/4054/v1/modifyOrderStatusToClose", method = RequestMethod.POST)
    ResponseResult<Integer> modifyOrderStatusToClose(@RequestBody OrderStatusToCloseCondition condition);
    /**
     * @description: 收退款记录
     * @author: shijinxing
     * @create: 2019-01-09 15:59
     **/
    @RequestMapping(value = "/orderManagement/4055/v1/findCollectAndRefundRecord", method = RequestMethod.POST)
    ResponseResult<OrderCollectAndRefundRecordVO> findCollectAndRefundRecord(@RequestBody OrderCollectAndRefundRecordCondition condition);
    /**
     * @description: 收发货记录
     * @author: shijinxing
     * @create: 2019-01-09 15:59
     **/
    @RequestMapping(value = "/orderManagement/4056/v1/findReceivingAndDeliveryRecord", method = RequestMethod.POST)
    ResponseResult<OrderReceivingAndDeliveryRecordVO> findReceivingAndDeliveryRecord(@RequestBody OrderReceivingAndDeliveryRecordCondition condition);
    /**
     * @description: 返利信息
     * @author: shijinxing
     * @create: 2019-01-09 15:59
     **/
    @RequestMapping(value = "/orderManagement/4059/v1/findRebateInformation", method = RequestMethod.POST)
    ResponseResult<List<OrderRebateInformationVO>> findRebateInformation(@RequestBody OrderRebateInformationCondition condition);
    /**
     * @description: 订单日志
     * @author: shijinxing
     * @create: 2019-01-09 15:59
     **/

    @RequestMapping(value = "/orderManagement/4060/v1/findOrderLog", method = RequestMethod.POST)
    ResponseResult<OrderLogVO> findOrderLog(@RequestBody OrderLogCondition condition);
}
@Component
class OrderManagementServicerClientFallback implements OrderManagementServiceClient, FallbackFactory<OrderManagementServiceClient> {

    private static final Logger logger = LoggerFactory.getLogger(OrderServiceFallback.class);
    private Throwable throwable;

    @Override
    public OrderManagementServiceClient create(Throwable throwable) {
        return null;
    }

    @Override
    public ResponseResult<PagedList<OrderManagementListVO>> findOrderManagementList(OrderManagementListCondition condition) {
        logger.error("获取订单列表失败，OrderManagementServiceClient -> findOrderManagementList", throwable);
        return new ResponseResult<>(BusinessCode.CODE_1001);
    }

    @Override
    public ResponseResult<OrderDeliverGoodsInfoVO> getDeliverGoodsInfo(OrderDeliverGoodsInfoCondition condition) {
        logger.error("获取待发货信息失败，OrderManagementServiceClient -> getDeliverGoodsInfo", throwable);
        return new ResponseResult<>(BusinessCode.CODE_1001);
    }

    @Override
    public ResponseResult<Integer> saveDeliverGoods(OrderDeliverGoodsInfoCondition condition) {
        logger.error("保存发货信息失败，OrderManagementServiceClient -> saveDeliverGoods", throwable);
        return new ResponseResult<>(BusinessCode.CODE_1001);
    }

    @Override
    public ResponseResult<OrderShoppingListVO> findShoppingList(OrderShoppingListCondition condition) {
        logger.error("获取购物清单失败，OrderManagementServiceClient -> findShoppingList", throwable);
        return new ResponseResult<>(BusinessCode.CODE_1001);
    }

    @Override
    public ResponseResult<OrderDistributionListVO> findDistributionList(OrderDistributionListCondition condition) {
        logger.error("获取配货清单失败，OrderManagementServiceClient -> findDistributionList", throwable);
        return new ResponseResult<>(BusinessCode.CODE_1001);
    }

    @Override
    public ResponseResult<OrderManagementDetailsVO> findOrderDetails(OrderDetailsCondition condition) {
        logger.error("获取订单详情失败，OrderManagementServiceClient -> findOrderDetails", throwable);
        return new ResponseResult<>(BusinessCode.CODE_1001);
    }

    @Override
    public ResponseResult<Integer> modifyOrderStatusToClose(OrderStatusToCloseCondition condition) {
        logger.error("关闭订单失败，OrderManagementServiceClient -> modifyOrderStatusToClose", throwable);
        return new ResponseResult<>(BusinessCode.CODE_1001);
    }

    @Override
    public ResponseResult<OrderCollectAndRefundRecordVO> findCollectAndRefundRecord(OrderCollectAndRefundRecordCondition condition) {
        logger.error("获取收退款记录失败，OrderManagementServiceClient -> findCollectAndRefundRecord", throwable);
        return new ResponseResult<>(BusinessCode.CODE_1001);
    }

    @Override
    public ResponseResult<OrderReceivingAndDeliveryRecordVO> findReceivingAndDeliveryRecord(OrderReceivingAndDeliveryRecordCondition condition) {
        logger.error("获取收发货记录失败，OrderManagementServiceClient -> findReceivingAndDeliveryRecord", throwable);
        return new ResponseResult<>(BusinessCode.CODE_1001);
    }

    @Override
    public ResponseResult<List<OrderRebateInformationVO>> findRebateInformation(OrderRebateInformationCondition condition) {
        logger.error("获取返利信息失败，OrderManagementServiceClient -> findRebateInformation", throwable);
        return new ResponseResult<>(BusinessCode.CODE_1001);
    }

    @Override
    public ResponseResult<OrderLogVO> findOrderLog(OrderLogCondition condition) {
        logger.error("获取订单日志失败，OrderManagementServiceClient -> findOrderLog", throwable);
        return new ResponseResult<>(BusinessCode.CODE_1001);
    }
}